package com.ruoyi.accountant.mapper;

import com.ruoyi.accountant.domain.Account;
import com.ruoyi.accountant.domain.AccountExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.jpa.repository.Query;

public interface AccountMapper<findByAname> {
    int countByExample(AccountExample example);

    int deleteByExample(AccountExample example);

    int deleteByPrimaryKey(Long aid);

    int insert(Account record);

    int insertSelective(Account record);

    List<Account> selectByExample(AccountExample example);

    Account selectByPrimaryKey(Long aid);

    int updateByExampleSelective(@Param("record") Account record, @Param("example") AccountExample example);

    int updateByExample(@Param("record") Account record, @Param("example") AccountExample example);

    int updateByPrimaryKeySelective(Account record);

    int updateByPrimaryKey(Account record);

    /***
     * 根据删除状态查询
     * @param deleted
     * @return
     */

    List<Account> findAllByDeleted(@Param("deleted")Integer deleted);

    /***
     * 根据名称查询
     * @param accountName
     * @return
     */
//    Account findTop1ByAname(String accountName);
    Account findByAname(@Param("aname")String aname);

    @Select("select * from t_account where aid in (select t.in_account from t_transaction_detail as t where t.dtype = '应收款' group by t.in_account)")
    List<Account> findInaccountByIds();

    @Select("select * from t_account where aid in (select t.in_account from t_transaction_detail as t where t.dtype = '应付款' group by t.in_account)")
    List<Account> findOutaccountByIds();
}